# See http://twistedmatrix.com/documents/8.2.0/core/howto/servers.html

from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor
import random

class QOTD(Protocol):
    def __init__(self):
        f = open('quotes.txt')
        self.quotes = f.read().split(r'%')
        f.close()
    def connectionMade(self):
        self.transport.write(random.choice(self.quotes))
        self.transport.loseConnection()

factory = Factory()
factory.protocol = QOTD

reactor.listenTCP(10017 ,factory)
reactor.run()
